import React, { Component } from 'react';
import './iconfont.css'
import headModuls from './publichead.module.scss'
import store from '../../redux/store/index'
import { getCityLocat, getCityHot, getCityGroup } from '../../redux/actionCreators/home_action/index'
//import {BrowserRouter as Router, Link, Route} from 'react-router-dom'
//import {withRouter} from 'react-router-dom'
import { connect } from "react-redux";

let style={
    color:'#ffff',
    fontSize:'30px',
    marginTop:'5px'
}
class public_head extends Component {
    componentDidMount(){
        store.dispatch(getCityLocat())
    }
    getCity=()=>{
        console.log(this.props);
        store.dispatch(getCityHot())
        store.dispatch(getCityLocat())
        store.dispatch(getCityGroup())
      this.props.history.push('/home/city')

    }
    render() {
        // var tok=localStorage.getItem('token')
        // console.log(tok);
        return (
            <div className={headModuls.head}>
                <div className={headModuls.headleft}>
                    <div className={headModuls.homelocate}>
                        <div className={headModuls.locateleft} onClick={this.getCity}>
                            <i style={style}className='iconfont icon-weizhi'></i>
                        </div>
                        <div className={headModuls.locateright} onClick={this.getCity} >
                            <span>{this.props.locatcity && this.props.locatcity.name}</span>
                        </div>
                    </div>
                </div>
                <div>
                <div className={headModuls.headright,headModuls.active}>
                
                    <span>登录</span>
                    <span> | </span>
                    <span>注册</span>
                </div>
                <div className={headModuls.headright}>
                <span>欢迎，{this.props.token && this.props.token.user_id}</span>
                {/* <span>欢迎，</span> */}
                
            </div>
                </div>
            </div>
        );
    }

}
export default connect((state) => {
   
    return {

        groupcity: state.homeReducer.groupcity,
        hotcity: state.homeReducer.hotcity,
        locatcity: state.homeReducer.locatcity,
        idcity:state.homeReducer.idcity,
        token:state.loginReducer.token
    }
}, null)(public_head);

